package com.atguigu.srb.base.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.function.Predicate;

@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket adminApiConfig(){
        return  new Docket(DocumentationType.SWAGGER_2)
                .groupName("adminApi")
                .apiInfo(adminApiInfo())
                .select().paths(Predicates.and(PathSelectors.regex("/admin/.*"))).build();
    }


     //管理员文档描述
    private ApiInfo adminApiInfo(){
        return new ApiInfoBuilder().title("金融管理系统").description("本文档描述金融用户管理系统的各个模块接口的使用")
                .version("9.9.9")
                .contact(new Contact("龙哥","https://store.steampowered.com/"
                        ,"99999991515@xxx.com")).build();
    }

    @Bean
    public Docket webApiConfig(){
        return  new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(webApiInfo())
                .groupName("webApi").select().paths(Predicates.and(PathSelectors.regex("/api/.*"))).build();
    }

    //用户文档描述
    private ApiInfo webApiInfo(){
        return new ApiInfoBuilder().title("欢迎访问金融网站").description("尚荣宝欢迎您的到来")
                .version("9.9.9")
                .contact(new Contact("龙哥","https://store.steampowered.com/"
                        ,"99999991515@xxx.com")).build();
    }

}
